package com.doitedu.doit30.hbase.client;

import com.doitedu.doit30.hbase.utils.HbaseUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
import org.apache.hadoop.hbase.client.Connection;

/**
 * @Date 22.6.9
 * @Created by HANGGE
 * @Description
 * 修改表结构
 */
public class _02ModifyTable {
    public static void main(String[] args) throws Exception {
        Connection conn = HbaseUtil.getHbaseConnection();
        Admin admin = HbaseUtil.getAdmin(conn);
        // 删除列族
       // admin.deleteColumnFamily(TableName.valueOf("tb_java2") , "cf2".getBytes());
        ColumnFamilyDescriptorBuilder builder = ColumnFamilyDescriptorBuilder.newBuilder("base_info".getBytes());
        builder.setMaxVersions(4) ;
        ColumnFamilyDescriptor familyDescriptor = builder.build();
        // 添加列族
       // admin.addColumnFamily(TableName.valueOf("tb_java2") , cf);
        // 修改列族属性
        admin.modifyColumnFamily(TableName.valueOf("tb_java2") , familyDescriptor);
        conn.close();
        admin.close();

    }
}
